<template>
  <div class="goods-tabs">
    <nav>
      <a @click="flag = 0" :class="{ active: flag == 0 }" href="javascript:;"
        >商品详情</a
      >
      <a @click="flag = 1" :class="{ active: flag == 1 }" href="javascript:;"
        >商品评价<span>({{ goods.commentCount }}+)</span></a
      >
    </nav>
    <!-- 切换内容的地方 -->
    <!-- 商品详情 -->
    <GoodsDetails v-if="flag == 0"></GoodsDetails>
    <!-- 商品评价 -->
    <GoodsComment v-else></GoodsComment>
  </div>
</template>

<script>
import { ref, reactive, toRefs, inject } from "vue";
import GoodsDetails from "./goodsDetails.vue";
import GoodsComment from "./goodsComment.vue";
export default {
  setup(props, { emit }) {
    const goods = inject("goods");
    let flag = ref(0);
    console.log(goods.value);
    return { goods, flag };
  },
  components: { GoodsDetails, GoodsComment },
};
</script>

<style lang="scss" scoped>
.goods-tabs {
  min-height: 600px;
  background: #fff;
  nav {
    height: 70px;
    line-height: 70px;
    display: flex;
    border-bottom: 1px solid #f5f5f5;
    a {
      padding: 0 40px;
      font-size: 18px;
      position: relative;
      > span {
        color: $priceColor;
        font-size: 16px;
        margin-left: 10px;
      }
      &:first-child {
        border-right: 1px solid #f5f5f5;
      }
      &.active {
        &::before {
          content: "";
          position: absolute;
          left: 40px;
          bottom: -1px;
          width: 72px;
          height: 2px;
          background: $xtxColor;
        }
      }
    }
  }
}
</style>
